<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8" import="java.util.ArrayList,java.io.File,java.io.FileReader,utility.Input"%>

<%
 
  String path=request.getContextPath();
  String Dpath=getServletContext().getRealPath(path); 
  Dpath=Dpath.substring(0,Dpath.lastIndexOf("/"));
  String LocalPluginPath =Dpath+"/Edit/plugins";
  String LocalSkinPath =   Dpath+"/Edit/skins";
   
%>

<html>
<head>


  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>Report Registeration</title>
  <link rel="stylesheet" href="full_example.css" />
  <style type="text/css">
    h1 {font: bold 22px "Staccato222 BT", cursive;}
    form, p {margin: 0px; padding: 0px;}
    label { display:block;}
  </style>
  
  <script language="JavaScript" type="text/javascript">
  var settings = null;
  settings = {
    width: "auto",
    height: "auto",
    sizeIncludesBars: true,
    sizeIncludesPanels: true,
    statusBar: true,
    htmlareaPaste: false,
        mozParaHandler: "best",
    getHtmlMethod: "DOMwalk",
    undoSteps: 20,
    undoTimeout: 500,
    changeJustifyWithDirection: false,
    fullPage: false,
    pageStyle: "",
    baseHref: null,
    expandRelativeUrl: true,
    stripBaseHref: true,
    stripSelfNamedAnchors: true,
    only7BitPrintablesInURLs: true,
    sevenBitClean: false,
    killWordOnPaste: true,
    makeLinkShowsTarget: true,
    flowToolbars: true,
    stripScripts: false,
    CharacterMapMode: "popup",
    ListTypeMode: "toolbar",
    showLoading: false,
    showChar: true,
    showWord: true,
    showHtml: true
  };


    function getCookieVal (offset) {
      var endstr = document.cookie.indexOf (";", offset);
      if (endstr == -1)
        endstr = document.cookie.length;
      return unescape(document.cookie.substring(offset, endstr));
    }

    function getCookie (name) {
      var arg = name + "=";
      var alen = arg.length;
      var clen = document.cookie.length;
      var i = 0;
      while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg)
          return getCookieVal (j);
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
      }
      return null;
    }

    function setCookie (name, value) {
      var argv = setCookie.arguments;
      var argc = setCookie.arguments.length;
      var expires = (argc > 2) ? argv[2] : null;
      var path = (argc > 3) ? argv[3] : null;
      var domain = (argc > 4) ? argv[4] : null;
      var secure = (argc > 5) ? argv[5] : false;
      document.cookie = name + "=" + escape (value) +
        ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
        ((path == null) ? "" : ("; path=" + path)) +
        ((domain == null) ? "" : ("; domain=" + domain)) +
        ((secure == true) ? "; secure" : "");
    }

  function _onResize() {
    var sHeight;
    if (window.innerHeight) sHeight = window.innerHeight;
    else if (document.body && document.body.offsetHeight) sHeight = document.body.offsetHeight;
    else return;
    if (sHeight>270) {
      sHeight = sHeight - 245;
     }
     
     else {
      sHeight = 30
    }
    var div = document.getElementById("div_plugins");
    div.style.height = sHeight + "px";
  }

  
function Dialog(url, action, init)
 {
  if (typeof init == "undefined") {
    init = window;	// pass this window object by default
  }
  Dialog._geckoOpenModal(url, action, init);
 };
 

Dialog._parentEvent = function(ev) 
{
  setTimeout( function() { if (Dialog._modal && !Dialog._modal.closed) { Dialog._modal.focus() } }, 50);
  if (Dialog._modal && !Dialog._modal.closed) {
    agt = navigator.userAgent.toLowerCase();
    is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    if (is_ie) {
      ev.cancelBubble = true;
      ev.returnValue = false;
    } else {
      ev.preventDefault();
      ev.stopPropagation();
    }
  }
};


// should be a function, the return handler of the currently opened dialog.
Dialog._return = null;

// constant, the currently opened dialog
Dialog._modal = null;

// the dialog will read it's args from this variable
Dialog._arguments = null;

Dialog._geckoOpenModal = function(url, action, init) {
  var dlg = window.open(url, "hadialog",
            "toolbar=no,menubar=no,personalbar=no,width=10,height=10," +
            "scrollbars=no,resizable=yes,modal=yes,dependable=yes");
  Dialog._modal = dlg;
  Dialog._arguments = init;

  // capture some window's events
  function capwin(w) {
//		Xinha._addEvent(w, "click", Dialog._parentEvent);
//		Xinha._addEvent(w, "mousedown", Dialog._parentEvent);
//		Xinha._addEvent(w, "focus", Dialog._parentEvent);
  };
  // release the captured events
  function relwin(w) {
//		Xinha._removeEvent(w, "click", Dialog._parentEvent);
//		Xinha._removeEvent(w, "mousedown", Dialog._parentEvent);
//		Xinha._removeEvent(w, "focus", Dialog._parentEvent);
  };
  capwin(window);
  // capture other frames
  for (var i = 0; i < window.frames.length; capwin(window.frames[i++]));
  // make up a function to be called when the Dialog ends.
  Dialog._return = function (val) {
    if (val && action) {
      action(val);
    }
    relwin(window);
    // capture other frames
    for (var i = 0; i < window.frames.length; relwin(window.frames[i++]));
    Dialog._modal = null;
  };
};

  function fExtended () {
    Dialog("Extended.html", function(param) {
      if(param) {
        settings.width = param["width"];
        settings.height = param["height"];
        settings.sizeIncludesBars = (param["sizeIncludesBars"]=="true");
        settings.sizeIncludesPanels = (param["sizeIncludesPanels"]=="true");
        settings.statusBar = (param["statusBar"]=="true");
        settings.htmlareaPaste = (param["htmlareaPaste"]=="true");
        settings.mozParaHandler = param["mozParaHandler"];
        settings.getHtmlMethod = param["getHtmlMethod"];
        settings.undoSteps = param["undoSteps"];
        settings.undoTimeout = param["undoTimeout"];
        settings.changeJustifyWithDirection = (param["changeJustifyWithDirection"]=="true");
        settings.fullPage = (param["fullPage"]=="true");
        settings.pageStyle = param["pageStyle"];
        settings.baseHref = param["baseHref"];
        settings.expandRelativeUrl = (param["expandRelativeUrl"]=="true");
        settings.stripBaseHref = (param["stripBaseHref"]=="true");
        settings.stripSelfNamedAnchors = (param["stripSelfNamedAnchors"]=="true");
        settings.only7BitPrintablesInURLs = (param["only7BitPrintablesInURLs"]=="true");
        settings.sevenBitClean = (param["sevenBitClean"]=="true");
        settings.killWordOnPaste = (param["killWordOnPaste"]=="true");
        settings.makeLinkShowsTarget = (param["makeLinkShowsTarget"]=="true");
        settings.flowToolbars = (param["flowToolbars"]=="true");
        settings.stripScripts = (param["stripScripts"]=="true");
        settings.CharacterMapMode = param["CharacterMapMode"];
        settings.ListTypeMode = param["ListTypeMode"];
        settings.showLoading = (param["showLoading"]=="true");
        settings.showChar = (param["showChar"]=="true");
        settings.showWord = (param["showWord"]=="true");
        settings.showHtml = (param["showHtml"]=="true");
      }
    }, settings );
  }

  function init(){
    var co = getCookie('co_ext_Xinha');
    if(co!=null){
      var co_values;
      var co_entries = co.split('###');
      alert("co-value"+co_entries);
      
      for (var i in co_entries) {
        co_values = co_entries[i].split('=');
        if(co_values[0]=='plugins') {
          for(var x = 0; x < document.forms[0].plugins.length; x++) {
            if(co_values[1].indexOf(document.forms[0].plugins[x].value)!=-F1) {
              document.forms[0].plugins[x].checked = true;
            }
          }
        } else if(co_values[0]!='') {
          document.getElementById(co_values[0]).value = co_values[1];
        }
      }
    }
    _onResize();
  };

  window.onresize = _onResize;
  window.onload = init;
  </script>
</head>

<body>
  <form action="ext_example-body.html" target="body" name="fsettings" id="fsettings">
  <h1>Report Registeration</h1>
    <fieldset>
      <legend>Settings</legend>
        <label>
          Number of Editors: <input type="text" name="num" id="num" value="1" style="width:25;" maxlength="2"/>
        </label>
        <label>
          Language:
          <select name="lang" id="lang">
          <option value="en">English</option>
          <option value="de">German</option>
          <option value="fr">French</option>
          <option value="it">Italian</option>
          <option value="no">Norwegian</option>
          <option value="pl">Polish</option>
          <option value="ja">Japanese</option>
          </select>
        </label>
        <label>
          Skin:
          <select name="skin" id="skin">
          <option value="">-- no skin --</option>
<%         
     try
     {
     File skindir= new File(LocalSkinPath);    
     File[] skinlist=skindir.listFiles();
       
      
     for(int i=0;i<skinlist.length;i++)
         {
           if(skinlist[i].isDirectory())
          
               {
                String skinName=skinlist[i].getAbsolutePath();
                skinName=skinName.substring(skinName.lastIndexOf("/")+1);
                out.println("<option value='"+skinName+"'>"+skinName +"</option>");
               }
         }
        
     
     }
  catch(Exception e)
  {
      e.printStackTrace();
  }
       
  %>         
    
     </select>
  </label>
 
  <center>
      <input type="button" value="extended Settings" onClick="fExtended();" />
  </center>

    </fieldset>
    
    <fieldset>
      <legend>Plugins</legend>
      <div id="div_plugins" style="width:100%; overflow:auto">


        
        
   <%

 
  try
     {
     File plugindir= new File(LocalPluginPath);    
     File[] list=plugindir.listFiles();
       
      
     for(int i=0;i<list.length;i++)
         {
           if(list[i].isDirectory())
          
               {
               String pluginname=list[i].getAbsolutePath();
                pluginname=pluginname.substring(pluginname.lastIndexOf("/")+1);
                out.println("<label> <input type='checkbox' name='plugins' id='plugins' value='"+pluginname+"' checked='yes'>"+pluginname+" </label>");
               }
         }
        
     
     }
  catch(Exception e)
  {
      e.printStackTrace();
  }


 %> 

</div>
    </fieldset>
    <center><button type="submit">reload editor</button></center>

        <textarea id="myTextarea0" style="display:none">
            <p>Open Source Co-operative is a participatory movement where talented people pool together to create 
          ventures and offer products and services to entrepreneurs and consumers in a open and transparent 
          environment. The Technology Division of Open Source Co-operative will offer a variety of technology 
          and related expertise to clients all over the world on a on-demand basis such that we can add significant 
          value to both our clients and individual service providers.</p>

          <ul>
            <li>  Business Consultants </li>
            <li>  Technology Consultants and Architects </li>
            <li> Software Developers in various languages such as Java, .NET, PHP, Python, Ruby, C, C++ etc.
                Branding and UI Experts, Graphic Designers and Animation Experts </li>
            <li> Online Marketers </li>
            <li> Infrastructure Managers, Linux Administrators </li> 
             <li>Software Testing Professionals </li>
             <li> Functional/Domain Experts in various industries </li>
             <li> Content Writers and Translators</li>
             <li>Mobile and Embedded Technology Experts</li>  
            <li> Database Administrators   </li>
            <li> Nunc sit amet metus in tortor semper mattis. </li>
          </ul> 
         
        </textarea>

  </form>
  <script type="text/javascript">
      
    top.frames["body"].location.href = document.location.href.replace(/ext_example-menu\.jsp.*/, 'ext_example-body.html')
    var _oldSubmitHandler = null;
    if (document.forms[0].onsubmit != null)
     {
      _oldSubmitHandler = document.forms[0].onsubmit;
     }
  

    //document.forms[0].onsubmit = frame_onSubmit;
  </script>

</body>
</html>
